<extend name="Base/base" />
<block name='head'>
    <!--文件上传-->
    <script type="text/javascript" src="/Public/Cropper/js/ajaxfileupload.js" ></script>
    <style>
    </style>
</block>
<block name="content"> 
    <section class="larry-wrapper" style="padding-top:20px">
        <div class="row pege-storage" id="pege-storage">
            <div class="col-lg-12 col-sm-12">
                <div class="layui-row btnWrap">
                    <button class="layui-btn layui-btn-normal importBtn" id="upload">导入Excel</button>
                    <a class="layui-btn downloadBtn" href="/Public/examples.xlsx" download="物品入库表.xlsx">下载Excel模板</a>
                    <input type="file" id="inputImage" name='imgfile' style="display:none">
                    <input type="hidden" id="filename" name="uploads" value="{$uploads[0].uploadsName}">
                    <input type="hidden" id="fileurl" name="uploads_url" value="{$uploads[0].uploadsUrl}">
                </div>
                <form class="submitForm">
                    <div class="layui-row">
                        <div class="layui-inline">
                            <label class="layui-form-label">类别：</label>
                            <div class="layui-input-inline">
                                <select class="layui-input search_input" name="type" style="min-width: 120px;">
                                    <foreach name="cates" item="cate">
                                    <option value="{$cate.id}">{$cate.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">凭证号：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="number" placeholder="为空默认生成" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="create_time" placeholder="为空默认当前时间" class="layui-input datepickerInput">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <a class="layui-btn layui-btn-normal categoryBtn" data-ctrl="goods">新增类别</a>
                        </div>
                    </div>
                    <div class="layui-row">
                        <table class="layui-table setTabBg" id="storageTab" lay-skin="line">
                            <colgroup>
                                <col width="20%" />
                                <col width="20%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="12%" />
                                <col width="20%" />
                                <col width="8%" />
                            </colgroup>
                            <thead>
                                <tr>
                                    <th>物品名称</th>
                                    <th>规格型号</th>
                                    <th>数量</th>
                                    <th>单位</th>
                                    <th>合计金额</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><input type="text" class="layui-input goods-name" name="name[]"></td>
                                    <td><input type="text" class="layui-input" name="model[]"></td>
                                    <td><input type="text" class="layui-input count" name="count[]"></td>
                                    <td><input type="text" class="layui-input" name="unit[]"></td>
                                    <td><input type="text" class="layui-input price" name="price[]"></td>
                                    <td><input type="text" class="layui-input" name="remark[]"></td>
                                    <td>
                                        <img src="/Public/Admin/images/add.png" class="pointer addBtn"/>
                                        <img src="/Public/Admin/images/del.png" class="pointer delBtn"/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <a class="layui-btn submitBtn ajax-post btn-submit" id="aaa" data-url="{:U('putGoods')}" data-form="">提交</a>
                    </div>
                </form>
            </div>
        </div>
        <input type="hidden" id="backUrl" value="{:U('index')}">
    </section>
</block>
<block name="script">
    <script type="text/javascript" src="/Public/Admin/js/goods.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/common.js" ></script>
    <script type="text/javascript">
        $(initAddCate());
        $(initGoods());
        $(dateTime(0));
        $(initUploadGoods("{:U(CONTROLLER_NAME.'/upload')}"));
        layui.use(['jquery', 'layer', 'element'], function () {
            window.jQuery = window.$ = layui.jquery;
            window.layer = layui.layer;
            window.element = layui.element();
        });

        //检查表单
        $('.ajax-post').on('click', function () {
            var flag = true;
            $('body').find('.goods-name').each(function(){
                if($(this).val() == ''){
                    layer.msg('请填写物品名称');
                    flag = false;
                }
            })
            $('body').find('.count').each(function(){
                if($(this).val() == ''){
                    layer.msg('请填写物品数量');
                    flag = false;
                }
            })
            $('body').find('.price').each(function(){
                if($(this).val() == ''){
                    layer.msg('请填写物品金额');
                    flag = false;
                }
            })
            
            
            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })

    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
</block>

